package com.hd.sup.modules.alarm.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hd.common.constant.BizConstant;
import com.hd.common.utils.DateUtil;
import com.hd.common.utils.GenUtil;
import com.hd.common.utils.ValueUtils;
import com.hd.sup.modules.alarm.mapper.AlarmDetailMapper;
import com.hd.sup.modules.alarm.model.AlarmDetail;
import com.hd.sup.modules.alarm.model.AlarmRule;
import com.hd.sup.modules.alarm.service.IAlarmDetailService;
import com.hd.sup.modules.alarm.util.TemplateUtils;
import com.hd.sup.modules.vehicle.model.VehicleAlarmDailyStatis;
import com.hd.sup.modules.vehicle.model.VehicleEndPos;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * <p>
 * 报警明细表 服务实现类
 * </p>
 *
 * @author chentl123
 * @since 2020-12-28
 */
@Slf4j
@Service
public class AlarmDetailServiceImpl extends ServiceImpl<AlarmDetailMapper, AlarmDetail> implements IAlarmDetailService {

    public static final int NIGHT_CONTINUOUS_MINUTES = 2;
    public static final int SECONDS_PER_MIN = 60;

    @Override
    public List<Map<String, Object>> getAlarmPage(Page page, AlarmDetail alarmDetail) {
        return this.baseMapper.getAlarmPage(page, alarmDetail);
    }

    @Override
    public Map<String, Object> getAlarmSumDistribution(VehicleAlarmDailyStatis param) {
        return this.baseMapper.getAlarmSumDistribution(param);
    }


    @Override
    public VehicleEndPos refreshAlarmFacotors(VehicleEndPos bo, VehicleEndPos old) {

        bo.setLastGpsTime(old.getGpsTime());
        bo.setLastUpdateTime(old.getUpdateTime() == null ? new Date() : old.getUpdateTime());
        bo.setLastLng(old.getLng());
        bo.setLastLat(old.getLat());
        return bo;
    }


    @Override
    public void refreshAlarmDetailData(AlarmDetail alarmDetail) {
        this.baseMapper.refreshAlarmDetailData(alarmDetail);
    }
}
